export function filterTreeData(treeData, filter) {
  let list = []

  treeData.forEach((item) => {
    let children = filterTreeData(item.children || [], filter)
    const listItem = { ...item, children }
    if (children.length > 0 || filter(item)) {
      list.push(listItem)
    }
  })
  return list
}


export function downloadTextFile(text, fileName) {
  const blob = new Blob([text], { type: 'text/plain' });
  const url = URL.createObjectURL(blob);
  
  const link = document.createElement('a');
  link.href = url;
  link.download = fileName;
  
  document.body.appendChild(link);
  link.click();
  
  document.body.removeChild(link);
  URL.revokeObjectURL(url);
}